﻿using System;
using System.Collections.Generic;
using System.Text;

namespace HBKY.Shop.Common
{
    public static class RandomHelper
    {
        #region 生成数字和字母的随机字符串
        /// <summary>
        /// 数字和字母随机数
        /// </summary>
        /// <param name="length">生成长度</param>
        /// <returns>返回指定长度的数字和字母的随机串</returns>
        public static string GetStringAndNumber(int length)
        {
            char[] arrChar = new char[]{
               'a','b','d','c','e','f','g','h','i','j','k','l','m','n','p','r','q','s','t','u','v','w','z','y','x',
               '0','1','2','3','4','5','6','7','8','9',
               'A','B','C','D','E','F','G','H','I','J','K','L','M','N','Q','P','R','T','S','V','U','W','X','Y','Z'};
            System.Text.StringBuilder num = new System.Text.StringBuilder();
            Random rnd = new Random(DateTime.Now.Millisecond);
            for (int i = 0; i < length; i++)
            {
                num.Append(arrChar[rnd.Next(0, arrChar.Length)].ToString());
            }
            return num.ToString();
        }
        #endregion
    }
}
